#!/bin/sh
PID_FILE=notice-app.pid
# resolve links - $0 may be a softlink
PRG="$0"

while [ -h "$PRG" ]; do
  ls=`ls -ld "$PRG"`
  link=`expr "$ls" : '.*-> \(.*\)$'`
  if expr "$link" : '/.*' > /dev/null; then
    PRG="$link"
  else
    PRG=`dirname "$PRG"`/"$link"
  fi
done

# Get standard environment variables
PRGDIR=`dirname "$PRG"`

# Only set CATALINA_HOME if not already set
[ -z "$GUDONG_HOME" ] && GUDONG_HOME=`cd "$PRGDIR" >/dev/null; pwd`

#echo "GUDONG_HOME: $GUDONG_HOME"
	
GUDONG_CP=.:./conf
export GUDONG_CP
for file in `find ./lib -name '*jar' | sort` ;
do
        GUDONG_CP=$GUDONG_CP:$file;
done;

#echo "GUDONG_CP: $GUDONG_CP"
export GUDONG_CP

shift
sudo mv gudong.log gudong.log.`date +%y-%m-%d-%H-%M` 2> /dev/null
sudo java -XX:PermSize=64M -XX:MaxPermSize=128m -Xms512m -Xmx512m  -XX:NewRatio=3 -XX:SurvivorRatio=4 -XX:MaxTenuringThreshold=4 -XX:TargetSurvivorRatio=90 -XX:+PrintTenuringDistribution -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -cp $GUDONG_CP com.comisys.app.server.start.server.start.ServiceServer.ServiceServer >gudong.log 2>&1 &
sudo echo $! > $PID_FILE
exit 0;
